Page({
  data: {
    nickname: '',
    grade: -1
  },
  onShow() {
    const grade = wx.getStorageSync('grade') || -1;
    const nickname = wx.getStorageSync('nickname') || '';
    this.setData({ grade, nickname });
  },
  toProfile() {
    const grade = wx.getStorageSync('grade') || -1;
    if (grade === -1) {
      wx.showToast({ title: '请先登录', icon: 'none' });
      wx.switchTab({ url: '/pages/index/index' });
      return;
    }
    wx.navigateTo({ url: '/pages/profile/index' });
  }
});